/*******************************************
  Jose Andres Lara Vecino

  Author       : $Author: cainlara@gmail.com $
  Last CheckIn : $Date: 2012-10-29 19:04:52 +0000 (Mon, 29 Oct 2012) $
  Revision     : $Revision: 108 $
*******************************************/

package generico;

import java.awt.event.ActionEvent;

import javax.swing.AbstractAction;
import javax.swing.ImageIcon;

/**
 * Super clase para las acciones.
 * 
 * @author jose.lara 06.06.2012
 */
public abstract class GenericoAccion extends AbstractAction {
    private static final long serialVersionUID = 1L;
    
    public GenericoAccion(String texto, ImageIcon icono) {
        this(texto, icono, texto);
    }
    
    public GenericoAccion(String texto, ImageIcon icono, String hint) {
        super(texto, icono);
        putValue(NAME, texto);
        putValue(SHORT_DESCRIPTION, hint);
    }
    
    @Override
    public abstract void actionPerformed(ActionEvent e);
    
    @Override
    public int hashCode() {
        return getValue(NAME).hashCode() + getValue(SHORT_DESCRIPTION).hashCode();
    }
    
    @Override
    public boolean equals(Object obj) {
        if(obj instanceof GenericoAccion) {
            return ((GenericoAccion)obj).hashCode() == this.hashCode();
        }
        
        return false;
    }
}
